package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"strings"
)

func main() {
	rAddr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:8888")
	conn, _ := net.DialUDP("udp", nil, rAddr)
	inputReader := bufio.NewReader(os.Stdin)
	for {
		sendStr, _ := inputReader.ReadString('\n')
		sendStr = strings.Trim(sendStr, "\r\n")
		conn.Write([]byte(sendStr))
		buffer := make([]byte, 1024)
		n, _ := conn.Read(buffer)
		fmt.Println(string(buffer[:n]))
	}
}
